import java.util.HashMap;
import java.util.HashSet;

public class generateRecipes {
    private HashMap<String, Recipe> recipes = new HashMap<String, Recipe>();
	

    private Recipe Rep1() {
        HashSet<Predicate> initialState = new HashSet<Predicate>();
        HashSet<Predicate> goalState = new HashSet<Predicate>();

        // We initiate the initialState below.
        initialState.add(new Ingredient("Vinegar"));
        initialState.add(new Ingredient("Bean"));
        initialState.add(new Ingredient("Tomato"));
        initialState.add(new Ingredient("Lettuce"));
        initialState.add(new Ingredient("Bacon"));
        initialState.add(new Ingredient("Pasta"));
        initialState.add(new Ingredient("Salt"));
        initialState.add(new Ingredient("Pepper"));
        initialState.add(new Ingredient("Potato"));

        // goalstate
        Chopped choppedTomato = new Chopped(new Ingredient("Tomato"));
        Chopped choppedLettuce = new Chopped(new Ingredient("Lettuce"));

        Fried friedBacon = new Fried(new Ingredient("Bacon"));
        Boiled boiledPasta = new Boiled(new Ingredient("Pasta"));

        Mixed mixed = new Mixed();
        mixed.AddToList(choppedTomato);
        mixed.AddToList(choppedLettuce);
        mixed.AddToList(new Ingredient("Vinegar"));
        mixed.AddToList(new Fried(new Ingredient("Bean")));

        Mixed mixed2 = new Mixed();
        mixed2.AddToList(mixed);
        mixed2.AddToList(new Ingredient("Salt"));
        mixed2.AddToList(new Ingredient("Pepper"));

        Mixed mixed3 = new Mixed();
        mixed3.AddToList(mixed2);
        mixed3.AddToList(friedBacon);
        // Initialising the goalState below.
        goalState.add(mixed3);
        goalState.add(boiledPasta);
        return new Recipe(initialState, goalState);
    }

    private Recipe Rep2() {
        /*
         * Spaghetti Bolognese
         */
        HashSet<Predicate> initialState = new HashSet<Predicate>();
        HashSet<Predicate> goalState = new HashSet<Predicate>();

        initialState.add(new Ingredient("Tomato"));
        initialState.add(new Ingredient("Ground Beef"));
        initialState.add(new Ingredient("Tomato Sauce"));
        initialState.add(new Ingredient("Onion"));
        initialState.add(new Ingredient("Garlic"));
        initialState.add(new Ingredient("Mushroom"));
        initialState.add(new Ingredient("Green Pepper"));
        initialState.add(new Ingredient("Oregano"));
        initialState.add(new Ingredient("Basil"));
        initialState.add(new Ingredient("Bay Leaf"));
        initialState.add(new Ingredient("Thyme"));
        initialState.add(new Ingredient("Ground Pepper"));
        initialState.add(new Ingredient("Olive Oil"));
        initialState.add(new Ingredient("Spaghetti"));
        initialState.add(new Ingredient("Parmesan Cheese"));

        Mixed mix = new Mixed();
        mix.AddToList(new Chopped(new Peeled(new Ingredient("Onion"))));
        mix.AddToList(new Chopped(new Ingredient("Mushroom")));
        mix.AddToList(new Chopped(new Ingredient("Garlic")));
        mix.AddToList(new Chopped(new Ingredient("Green Pepper")));

        Mixed mix2 = new Mixed();
        mix2.AddToList(new Fried(mix));
        mix2.AddToList(new Fried(new Ingredient("Ground Beef")));

        Mixed mix3 = new Mixed();
        mix3.AddToList(mix2);
        mix3.AddToList(new Chopped(new Ingredient("Tomato")));
        mix3.AddToList(new Ingredient("Tomato Sauce"));
        mix3.AddToList(new Ingredient("Basil"));
        mix3.AddToList(new Ingredient("Oregano"));
        mix3.AddToList(new Ingredient("Thyme"));
        mix3.AddToList(new Ingredient("Bay Leaf"));
        mix3.AddToList(new Ingredient("Ground Pepper"));

        Mixed mix4 = new Mixed();
        mix4.AddToList(new Boiled(new Ingredient("Spaghetti")));
        mix4.AddToList(new Ingredient("Olive Oil"));

        Mixed mix5 = new Mixed();
        mix5.AddToList(mix4);
        mix5.AddToList(new Ingredient("Parmesan Cheese"));

        goalState.add(new Boiled(mix3));
        goalState.add(mix5);

        return new Recipe(initialState, goalState);
    }

    private Recipe Rep3() {
        HashSet<Predicate> initialState3 = new HashSet<Predicate>();
        HashSet<Predicate> goalState3 = new HashSet<Predicate>();

        initialState3.add(new Ingredient("Tomato"));
        initialState3.add(new Ingredient("Spring Union"));
        initialState3.add(new Ingredient("Garlic"));
        initialState3.add(new Ingredient("Egg"));
        initialState3.add(new Ingredient("Sesame oil"));

        Chopped choppedTomato3 = new Chopped(new Ingredient("Tomato"));
        Chopped choppedSpringUnion3 = new Chopped(
                        new Ingredient("Spring Union"));
        Chopped choppedGarlic3 = new Chopped(new Ingredient("Garlic"));
        Beaten beatenEgg3 = new Beaten(new Ingredient("Egg"));
        Fried friedEgg3 = new Fried(beatenEgg3);
        Fried friedTomato3 = new Fried(choppedTomato3);
        Mixed mixedTE = new Mixed();
        mixedTE.AddToList(friedEgg3);
        mixedTE.AddToList(friedTomato3);
        Fried friedMixedTE = new Fried(mixedTE);
        Mixed finished = new Mixed();
        finished.AddToList(friedMixedTE);
        finished.AddToList(choppedSpringUnion3);
        finished.AddToList(choppedGarlic3);
        finished.AddToList(new Ingredient("Sesame oil"));

        goalState3.add(finished);

        return new Recipe(initialState3, goalState3);
    }
        
    private Recipe Rep5() {
        HashSet<Predicate> initialState = new HashSet<Predicate>();
        HashSet<Predicate> goalState = new HashSet<Predicate>();
        
        String Flour = "Flour";
        String Sugar = "Sugar";
        String CocoaPowder = "Cocoa Powder";
        String BakingPowder = "Baking Powder";
        String VanillaExtract = "Vanilla Extract";
        String Butter = "Butter";
        String Water = "Water";
        String Eggs = "Eggs";
        String ChocolateChips = "Chocolate Chips";
        String Walnuts = "Walnuts";
        
        String DarkChocolate = "Dark Chocolate";
        String LightCornSyrup = "Light Corn Syrup";
        String HotExpresso = "Hot Expresso";
        //Cake
        initialState.add(new Ingredient(Flour));
        initialState.add(new Ingredient(Sugar));
        initialState.add(new Ingredient(CocoaPowder));
        initialState.add(new Ingredient(BakingPowder));
        initialState.add(new Ingredient(VanillaExtract));
        initialState.add(new Ingredient(Butter));
        initialState.add(new Ingredient(Water));
        initialState.add(new Ingredient(Eggs));
        initialState.add(new Ingredient(ChocolateChips));
        initialState.add(new Ingredient(Walnuts));
        //Frosting
        initialState.add(new Ingredient(DarkChocolate));
        initialState.add(new Ingredient(LightCornSyrup));
        initialState.add(new Ingredient(HotExpresso));
        
        //Prepare Ingredients
        Boiled BoiledWater = new Boiled(new Ingredient(Water));
        Chopped ChoppedWalnuts = new Chopped(new Ingredient(Walnuts));
        Melted MeltedButter = new Melted(new Ingredient(Butter));
        Chopped ChoppedChocolate = new Chopped(new Ingredient(DarkChocolate));
        Beaten BeatenEggs = new Beaten(new Ingredient(Eggs));
        //Mix Flour, Sugar, Cocoa Powder, Baking Powder and Vanilla Extract
        Mixed MixedFlourSugarCocoaBakingVanilla = new Mixed();
        MixedFlourSugarCocoaBakingVanilla.AddToList(new Ingredient(Flour));
        MixedFlourSugarCocoaBakingVanilla.AddToList(new Ingredient(Sugar));
        MixedFlourSugarCocoaBakingVanilla.AddToList(new Ingredient(CocoaPowder));
        MixedFlourSugarCocoaBakingVanilla.AddToList(new Ingredient(BakingPowder));
        MixedFlourSugarCocoaBakingVanilla.AddToList(new Ingredient(VanillaExtract));
        //Mix Beaten Eggs, Melted Butter and Hot Water
        Mixed MixedEggsMeltedButterBoiledWater = new Mixed();
        MixedEggsMeltedButterBoiledWater.AddToList(BeatenEggs);
        MixedEggsMeltedButterBoiledWater.AddToList(MeltedButter);
        MixedEggsMeltedButterBoiledWater.AddToList(BoiledWater);
        //Mix the first mix with the second mix
        Mixed FirstMixMix = new Mixed();
        FirstMixMix.AddToList(MixedFlourSugarCocoaBakingVanilla);
        FirstMixMix.AddToList(MixedEggsMeltedButterBoiledWater);
        //Mix Chocolate Chips and Chopped Walnuts
        Mixed MixChocolateChipsNuts = new Mixed();
        MixChocolateChipsNuts.AddToList(new Ingredient(ChocolateChips));
        MixChocolateChipsNuts.AddToList(ChoppedWalnuts);
        //Mixed the large mix with the chocolate chips/chopped Walnuts mix
        Mixed SecondMixMix = new Mixed();
        SecondMixMix.AddToList(FirstMixMix);
        SecondMixMix.AddToList(MixChocolateChipsNuts);
        //Mix Butter (not melted), Chopped Chocolate, Light Corn Syrup and Hot Expresso
        Mixed MixButterChoppedChocolateSyrupCoffee = new Mixed();
        MixButterChoppedChocolateSyrupCoffee.AddToList(new Ingredient(Butter));
        MixButterChoppedChocolateSyrupCoffee.AddToList(ChoppedChocolate);
        MixButterChoppedChocolateSyrupCoffee.AddToList(new Ingredient(LightCornSyrup));
        MixButterChoppedChocolateSyrupCoffee.AddToList(new Ingredient(HotExpresso));
        //Mix Everything together
        Mixed FinalMixMix = new Mixed();
        FinalMixMix.AddToList(SecondMixMix);
        FinalMixMix.AddToList(MixButterChoppedChocolateSyrupCoffee);
        //Add to the goal state
        goalState.add(FinalMixMix);
        return new Recipe(initialState, goalState);
    }
    
    private Recipe Rep4() {
        HashSet<Predicate> initialState4 = new HashSet<Predicate>();
        HashSet<Predicate> goalState4 = new HashSet<Predicate>();

        initialState4.add(new Ingredient("Beef"));
        initialState4.add(new Ingredient("Cabbage"));
        initialState4.add(new Ingredient("Spring union"));
        initialState4.add(new Ingredient("Garlic"));
        initialState4.add(new Ingredient("Chilli bean source"));
        initialState4.add(new Ingredient("Flour"));
        initialState4.add(new Ingredient("Salt"));
        initialState4.add(new Ingredient("Spice"));
        initialState4.add(new Ingredient("Red Paprika"));
        initialState4.add(new Ingredient("Soya source"));
        initialState4.add(new Ingredient("Cooking wine"));
        initialState4.add(new Ingredient("Chilli powder"));
        initialState4.add(new Ingredient("Oil"));

        Chopped choppedBeaf = new Chopped(new Ingredient("Beef"));
        Chopped choppedCabbage = new Chopped(new Ingredient("Cabbage"));
        Chopped choppedSU = new Chopped(new Ingredient("Spring union"));
        Chopped choppedGarlic = new Chopped(new Ingredient("Garlic"));

        Mixed mixed2 = new Mixed();
        mixed2.AddToList(new Ingredient("Oil"));
        mixed2.AddToList(new Ingredient("Spice"));
        mixed2.AddToList(new Ingredient("Salt"));
        mixed2.AddToList(new Ingredient("Chilli bean source"));
        Fried friedSource = new Fried(mixed2,6);

        Mixed mixedYan = new Mixed();
        mixedYan.AddToList(choppedBeaf);
        mixedYan.AddToList(choppedCabbage);
        //mixedYan.AddToList(choppedGarlic);
        mixedYan.AddToList(friedSource);
        mixedYan.AddToList(new Ingredient("Soya source"));
        mixedYan.AddToList(new Ingredient("Cooking wine"));
        mixedYan.AddToList(new Ingredient("Salt"));
        mixedYan.AddToList(new Ingredient("Flour"));


        Mixed oilAndPap = new Mixed();
        oilAndPap.AddToList(new Ingredient("Oil"));
        oilAndPap.AddToList(new Ingredient("Red Paprika"));

        Fried friedVeg = new Fried(oilAndPap,4);

//		friedVeg.AddToList(choppedCabbage);
//		friedVeg.AddToList(choppedSU);
//		friedVeg.AddToList(new Ingredient("Salt"));

        Boiled meatSoup = new Boiled(mixedYan,10);
        ///meatSoup.AddToList(friedSource);

        Mixed mixed1 = new Mixed();
        mixed1.AddToList(friedVeg);
        mixed1.AddToList(meatSoup);
        mixed1.AddToList(new Ingredient("Chilli powder"));
        mixed1.AddToList(choppedGarlic);
        mixed1.AddToList(choppedSU);

        Mixed mixed3 = new Mixed();
        mixed3.AddToList(new Ingredient("Spice"));
        mixed3.AddToList(new Ingredient("Oil"));
        Fried lastOil = new Fried(mixed3);

        Mixed shuiZhuRou = new Mixed();
        shuiZhuRou.AddToList(mixed1);
        shuiZhuRou.AddToList(lastOil);

        goalState4.add(shuiZhuRou);

        return new Recipe(initialState4, goalState4);
    }
        
    public generateRecipes() {
        // ReadFromFile...
        recipes.put("Pasta salad with bacon", this.Rep1());
        recipes.put("Spaghetti bolognese", this.Rep2());
        recipes.put("Fried Tomato and Egg", this.Rep3());
        recipes.put("Shui Zhu Rou", this.Rep4());
        recipes.put("Scandinavian Brownies", this.Rep5());
        /* Potato mix recipe */
    }

    public HashMap<String, Recipe> GetRecipes() {
        return recipes;
    }
}
